package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 *
 */
@Service
public class UserService {
    //简单类型属性值注入
    @Value("登录")
    private String name;
    //对象类型属性值注入
    /*
    Autowired注解：自动装配，注入对象类型的数据
    1添加在属性上
    2添加在Set方法上
    3添加在构造方法上
     */

    //@Autowired
    private UserDao userDao;
    /*
    set()方法
     */
    //@Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    /*
        构造方法
         */
    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
